public class Test {
    //给定一个整型数组, 实现冒泡排序(升序排序)
    public static int[] bubble(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 1; j < arr.length-i; j++) {
                int temp;
                if(arr[j-1] > arr[j]) {
                    temp = arr[j-1];
                    arr[j-1] = arr[j];
                    arr[j] = temp;
                }

            }

        }
        return arr;
    }

    public static void main(String[] args) {
        int[] array = {5,8,1,6,9};
        int[] ret = bubble(array);
        for (int i = 0; i < ret.length; i++) {
            System.out.print(ret[i] + " ");

        }
    }
}
